
// * 操作数组元素的方法：push、pop、shift、unshift、indexOf、lastIndexOf、includes
// * 对整个数组操作的方法：slice、splice、concat、map、reduce、sort、filter、join、fill

let arr = [1,'2',true,{},[],Symbol(),7n]; // 一个包含 JS 七个基本数据类型的数组

// 操作将会展示 方法 的参数和返回值
// push
let arr1 = [...arr];
let result1 = arr1.push('daixa');
console.log(result1,arr1);

let arr2 = [...arr];
let result2 = arr2.pop();
console.log(result2,arr2);

console.log([].shift(),[].pop());

console.log(arr.indexOf(true,3),arr.lastIndexOf(true,-2));

// console.log(arr.splice(2,1,[8,8,8,8]),arr);

let arrfilter = [...arr];
console.log(arrfilter.filter(item => {
    return typeof item === 'object'?true:false;
}),arrfilter);

console.log('------------- arr:',arr);
let arrfill = [...arr];
arrfill.length = 10;
console.log(arrfill);
setTimeout(() => {
    console.log(arrfill.fill(8,6),arrfill);
})

console.log('--------------');
let arrsome = [...arr];
console.log("someResult:",arrsome.some((value,key,arr) => {
    console.log(value,key,arr);
    return value == 1;
}));


console.log('--------------');
let arrsort = [1,5,2,7,3];
console.log(arrsort.sort((a,b) => {
    return a - b;
}),arrsort);


